<?php

namespace Home\Controller;

use Think\Controller;

class CollectController extends CommonController {

    public $appkey = '116bdf79fe13a';

    /**
     * [token token验证]
     * @return [type] [json]
     */
    public function __construct() {
        //$this->token();
    }

    public function collectlist() {
        $uid = I('post.uid', 0, 'intval');
        //$this->usertoken($uid);
        $pindex = I('post.pno', 1, 'intval');     //当前页码
        $psize = I('post.pgz', 10, 'intval');   //显示条数
        if (!$pindex)
            $pindex = 1;
        $pfirst = ($pindex - 1) * $psize;
        if (!$uid)
            returnApiError(1, '请传入用户uid');

        $Model = new \Think\Model(); // 实例化一个model对象 没有对应任何数据表

        $data = $Model->query("SELECT t.*,t1.goods_id,t1.goods_salenum,t1.goods_promotion_type FROM `listen_favorites` AS t 
            LEFT JOIN `listen_goods` AS t1  ON t.fav_id = t1.goods_id  AND t.fav_type = 'goods' WHERE t.member_id = $uid  limit ".$pfirst .','.$psize);
        if (!$data) {
            returnArr('数据为空');
        } else {
            returnApiSuccess('ok', $data);
        }
    }

}
